﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

namespace QLKH
{
    class Connection
    {
        private SqlConnection conn;
        private SqlDataAdapter adapter;
        public Connection()
        {
            adapter = new SqlDataAdapter();
            conn = new SqlConnection("data source=(local);initial catalog=QLKH;user=sa;password=123");
        }

        public DataTable ExecuteSelectQuery(String query, SqlParameter[] sqlparameter)
        {
            SqlCommand command = new SqlCommand(query,conn);
            if (sqlparameter != null)
                command.Parameters.AddRange(sqlparameter);
            adapter.SelectCommand = command;
            DataSet ds = new DataSet();
            adapter.Fill(ds);
            DataTable dt = ds.Tables[0];
            return dt;
        }
    }
}
